namespace Com.FirstSolver.Splash;

public abstract class ECFieldElement
{
	public abstract string FieldName { get; }

	public abstract int FieldSize { get; }

	public abstract BigInteger ToBigInteger();

	public abstract ECFieldElement Add(ECFieldElement b);

	public abstract ECFieldElement Subtract(ECFieldElement b);

	public abstract ECFieldElement Multiply(ECFieldElement b);

	public abstract ECFieldElement Divide(ECFieldElement b);

	public abstract ECFieldElement Negate();

	public abstract ECFieldElement Square();

	public abstract ECFieldElement Invert();

	public abstract ECFieldElement Sqrt();

	public abstract byte[] GetEncoded();

	public override bool Equals(object obj)
	{
		if (obj == this)
		{
			return true;
		}
		if (!(obj is ECFieldElement other))
		{
			return false;
		}
		return Equals(other);
	}

	protected bool Equals(ECFieldElement other)
	{
		return ToBigInteger().Equals(other.ToBigInteger());
	}

	public override int GetHashCode()
	{
		return ToBigInteger().GetHashCode();
	}

	public override string ToString()
	{
		return Utils.ToString(GetEncoded());
	}
}
